package com.coderg.gmall.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.coderg.gmall.model.user.UserAddress;
import com.coderg.gmall.user.mapper.UserAddressMapper;
import com.coderg.gmall.user.service.UserAddressService;
import com.coderg.gmall.user.util.GmallThreadLocalUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements UserAddressService {

    /**
     * 根据用户Id 查询用户的收货地址列表！
     *
     * @param
     * @return
     */
    @Override
    public List<UserAddress> findUserAddressListByUserId() {
        String userId = GmallThreadLocalUtils.getUserName();
        List<UserAddress> list =
                list(new LambdaQueryWrapper<UserAddress>().eq(UserAddress::getUserId, userId));
        return list;
    }
}
